﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.Class;
public partial class Admin_Account_Modules_visa_AddNew : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack) {
            ViewState["URLReferrer"] = Request.UrlReferrer.AbsoluteUri;
        }
    }

    private Boolean AddNew() {

        if (CMS.Check.CheckInt(txtCODE.Text)){
            CMSDataContext db = new CMSDataContext();
            wVISA visa = new wVISA();
            visa.ID = Convert.ToInt32(txtCODE.Text);
            visa.NAME = txtNAME.Text;
            db.wVISAs.InsertOnSubmit(visa);
            db.SubmitChanges();
            return true;
        }
        return false;
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (AddNew()) {
            Response.Redirect(ViewState["URLReferrer"].ToString());
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect(ViewState["URLReferrer"].ToString());
    }
}